<?php
/**
 * Cube solver
 *
 * @package Cuber
 * @since   Jul 22, 2007
 * @author  Christophe Thiriot
 */

jClasses::inc('cube~Cube');

/**
 * Cube solver
 *
 * @package Cuber
 */
interface CubeSolver 
{
    public function __construct(Cube $cubetosolve, CubeState $statetoobtain);

    public function solve();
}

class CrossSolver implements CubeSolver
{
    private $currentcube = null;

    private $targetstate = null;

    private $solvemap = array(
        "R2" => array(
            2  => '9|10|11|12',
            10 => '1.|2.|3.|4.|5.|6.|7.|8.'
        ),
        "R u R'" => array(
            2  => '9+|10+|11+|12+', 
            10 => '1.|2.|3.|4.|5.|6.|7.|8.'
        ),
        "u' R" => array(
            6  => '9|10|11|12',
            10 => '1.|2.|3.|4.|5.|6.|7.|8.'
        ),
        "R'" => array(
            6  => '9+|10+|11+|12+', 
            10 => '1.|2.|3.|4.|5.|6.|7.|8.'
        ),
        "R u' R" => array(
            10 => '9+|10+|11+|12+'
        ),
    );
    
    public function __construct(Cube $cubetosolve, CubeState $targetState)
    {
        $this->currentcube = $cubetosolve;
        $this->targetstate = $targetState;

        // translate the solve map to something usable
        foreach ($this->solvemap as &$state)
        {
            $state = new CubeState($state);
        }
    }

    public function solve()
    {
        $alg = '';
        while (false === $targetstate->validate($cube))
        {
            // look for a state that matches our cube ans apply the corresponding alg

        }
    }
}

class CubeState
{
    public __construct()
    {
        
    }

    public validate(Cube $cubetosolve)
    {

    }
}
?>
